/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2012
 */

package com.tech15.pub.dao;

import static cn.org.rapid_framework.util.ObjectUtils.isNotEmpty;

import java.util.Map;

import javacommon.base.BaseHibernateDao;

import org.springframework.stereotype.Repository;

import cn.org.rapid_framework.page.Page;
import cn.org.rapid_framework.page.PageRequest;

import com.tech15.pub.model.PubApps;
import com.tech15.pub.vo.query.PubAppsQuery;

@Repository
public class PubAppsDao extends BaseHibernateDao<PubApps,java.lang.Long>{

	public Class getEntityClass() {
		return PubApps.class;
	}
	
	public Page findByPageRequest(PageRequest<Map> pageRequest) {
		//XsqlBuilder syntax,please see http://code.google.com/p/rapid-xsqlbuilder
		// [column]为字符串拼接, {column}为使用占位符. 以下为图方便采用sql拼接,适用性能要求不高的应用,使用占位符方式可以优化性能. 
		// [column] 为PageRequest.getFilters()中的key
		String sql = "select t from PubApps t where 1=1 "
				+ "/~ and t.appname = '[appname]' ~/"
				+ "/~ and t.appurl = '[appurl]' ~/"
				+ "/~ and t.appsort = '[appsort]' ~/"
				+ "/~ and t.category = '[category]' ~/"
				+ "/~ and t.memo = '[memo]' ~/"
				+ "/~ order by [sortColumns] ~/";
		return pageQuery(sql,pageRequest);
	}
	
	public Page findPage(PubAppsQuery query) {
        //XsqlBuilder syntax,please see http://code.google.com/p/rapid-xsqlbuilder
        // [column]为字符串拼接, {column}为使用占位符. [column]为使用字符串拼接,如username='[username]',偷懒时可以使用字符串拼接 
        // [column] 为PageRequest的属性
		String sql = "select t from PubApps t where 1=1 "
			  	+ "/~ and t.appname = {appname} ~/"
			  	+ "/~ and t.appurl = {appurl} ~/"
			  	+ "/~ and t.issys = {issys} ~/"
			  	+ "/~ and t.appsort = {appsort} ~/"
			  	+ "/~ and t.category = {category} ~/"
			  	+ "/~ and t.isshfw = {isshfw} ~/"
			  	+ "/~ and t.memo = {memo} ~/"
				+ "/~ order by [sortColumns] ~/";
				
		return pageQuery(sql,query);
	}
	

}
